import { BaseEntity } from '../../base/entity/base';
import { Column, Entity, Index } from 'typeorm';

/**
 * 触发条件
 */
@Entity('automation_condition')
export class AutomationConditionEntity extends BaseEntity {
  @Column({ comment: '条件类型', dict: ['气象', '设备', '定时'], default: 0 })
  conditionType: number;

  @Column({
    comment: '气象条件类型',
    dict: ['温度', '湿度', '天气', 'PM2.5', '空气质量', '日落日出', '风速'],
    nullable: true,
  })
  weatherType: number;

  @Column({ comment: '城市编码', nullable: true })
  cityCode: string;

  @Column({ comment: '设备ID', nullable: true })
  deviceId: string;

  @Column({ comment: '设备属性字段', nullable: true })
  deviceField: string;

  @Column({ comment: '状态阈值', nullable: true })
  threshold: string;

  @Column({ comment: '触发时间(定时条件)', nullable: true })
  triggerTime: string;

  @Column({
    comment: '比较方式',
    dict: ['大于', '小于', '等于', '不等于', '大于等于', '小于等于'],
    nullable: true,
  })
  compareType: number;

  @Column({ comment: '条件描述', nullable: true })
  description: string;

  @Index()
  @Column({ comment: '流水线ID' })
  pipelineId: number;
}
